package com.a3dweijing.wetouch2.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.a3dweijing.wetouch2.Common.RefreshRecycler.ViewHolder;
import com.a3dweijing.wetouch2.R;
import com.a3dweijing.wetouch2.bean.AddressMsg;

import java.util.List;

/**
 * Created by Yxd on 2018/3/26.
 */

public class SpinnerAdapter extends BaseAdapter {
    private List<AddressMsg.AddressBean> bean;

    public SpinnerAdapter(List<AddressMsg.AddressBean> bean) {
        this.bean = bean;
    }

    @Override
    public int getCount() {
        return bean.size();
    }

    @Override
    public Object getItem(int i) {
        return bean.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;

        if (view == null) {
            view = View.inflate(viewGroup.getContext(), R.layout.item_spinner, null);
            holder = new ViewHolder();
            holder.tv = (TextView) view.findViewById(R.id.spinner_tv);

            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.tv.setText(bean.get(i).getArea_name());

        return view;
    }

    static class ViewHolder {
        private TextView tv;
    }
}
